#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/syslog.h>
#include <pthread.h>

#include "systemCall.h"
 
#define PRINTF_BUF_SIZE 16*1024
static char s_MsgBuf[PRINTF_BUF_SIZE];


void Print( const char *format, ... )
{
	va_list ap;
	va_start( ap, format );
	
	//s_PrintfMutex.Lock();
	vsnprintf( s_MsgBuf, sizeof(s_MsgBuf), format, ap );
	//s_PrintfMutex.Unlock();
	
	vfprintf( stderr, format, ap );
	va_end( ap );
}

int Strlen( const char *pstr )
{
	if( NULL != pstr )
	{
		return strlen( pstr );
	}

	return 0;
}

int ThreadCreate( pthread_t *threadId, void *(*threadFunc)(void*), void *arg )
{
	return pthread_create( threadId, NULL, threadFunc, arg );     
}

void Close( int fd )
{
	close( fd );
}

void *Memset(void *s, int c, int n)
{
	return memset( s, c, n);
}

int Memcmp( const void *s1, const void *s2, int n )
{
	return memcmp( s1, s2, n );
}

char *Strcpy( char *dest, const char *src)
{
	return strcpy( dest, src );
}

int Usleep( unsigned int usec )
{
	return usleep( usec );
}

void *Memcpy( void *dest, const void *src, int n )
{
	return memcpy( dest, src, n );
}

int Socket(int domain, int type, int protocol)
{
	return socket(domain, type, protocol);
}

int Setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
{
	return setsockopt(sockfd, level, optname,optval, optlen);
}

ssize_t Sendto(int sockfd, const void *buf, size_t len, int flags,const struct sockaddr *dest_addr, socklen_t addrlen)
{
	return sendto(sockfd, buf, len, flags,dest_addr, addrlen);
}

void Sprintf(char * buf, const char *format,...)
{
    va_list args;
    va_start(args,format);
    vsprintf(buf,format,args);
    va_end(args);
}


